package com.example.day08.homework;

public class ChineseTest {

    public static void main(String[] args) {
        System.out.println(chineseConversion(100));
        System.out.println((char)3);
    }
    public static final char[] chinese={'零','壹','贰','叁','肆','伍','陆','柒','捌','玖'};
    public static final char[] digit={'拾','佰','仟','萬'};
    public static String chineseConversion(int i){
        StringBuilder stringBuilder=new StringBuilder();
        int end=i;
        int j = -1;
        int temp=0;
        while (true){
            if(i==0) break;
            if(j!=-1&&chinese[i%10]!='零'){
                stringBuilder.append(digit[j]);
            }
            stringBuilder.append(chinese[i % 10]);
            if((chinese[i % 10]=='零')&&(chinese[(i /10)%10]=='零')){
                stringBuilder.deleteCharAt(temp--);
            }
            i=i/10;
            j++;
            temp++;
        }
        if(end%10==0) stringBuilder.deleteCharAt(0);

        if(end==10)  return  "拾";
        return stringBuilder.reverse().toString();
    }
}
